package cn.bdqn.controller;

import cn.bdqn.entity.Staff;
import cn.bdqn.service.StaffService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import javax.annotation.Resource;

@RestController
@RequestMapping("staff")
public class StaffController {
    @Resource
    private StaffService staffService;

    @GetMapping
    public ResponseEntity<List<Staff>> queryAll() {
        return ResponseEntity.ok(this.staffService.queryAll());
    }

    @GetMapping("{id}")
    public ResponseEntity<Staff> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.staffService.queryById(id));
    }

    @PostMapping
    public ResponseEntity<Staff> add(Staff staff) {
        return ResponseEntity.ok(this.staffService.insert(staff));
    }

    @PutMapping
    public ResponseEntity<Staff> edit(Staff staff) {
        return ResponseEntity.ok(this.staffService.update(staff));
    }
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.staffService.deleteById(id));
    }

}

